package com.home.viewpager2demo

import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.viewpager2.adapter.FragmentStateAdapter

class MyFragmentStateAdapter : FragmentStateAdapter {

  private val fragments:List<Fragment>

  constructor(
    fragmentActivity: FragmentActivity,
    fragments: List<Fragment>
  ) : super(fragmentActivity){
    this.fragments = fragments
  }

  override fun getItemCount(): Int {
    return fragments.size
  }

  override fun createFragment(position: Int): Fragment {
    return fragments[position]
  }
}